#include "../src/fileControl.hpp"
#include <iostream>
#include <fstream>
#include <stdexcept>

void TouchSomeFile(std::string path)
{
  std::ofstream file(path);
  if(!file.is_open())
    throw std::runtime_error("无法创建测试文件");
  file.close();
}

int main()
{
  auto printListData=[](const std::vector<std::string> & list){
    for(const auto & i : list)
    {
        std::cout<<i<<",";
    }
    std::cout<<std::endl;
  };

  if(!std::filesystem::exists("/tmp/test_workSpace"))
  {
    std::filesystem::create_directory("/tmp/test_workSpace");
  }
  fileControl file("/tmp/test_workSpace");
  file.CreateProjectDir("AA");
  file.CreateTaskDir("AA","tt");
  std::cout<<"Project List"<<std::endl;
  printListData(file.ScanProjectDir());
  std::cout<<"Task List"<<std::endl;
  printListData(file.ScanTaskDir("AA"));
  TouchSomeFile("/tmp/test_workSpace/AA/tt/cdavaav.mkv");
  TouchSomeFile("/tmp/test_workSpace/AA/tt/cdjakvaa.mkv");
  TouchSomeFile("/tmp/test_workSpace/AA/tt/cdjakvaa.jvd");
  std::cout<<"Scan File"<<std::endl;
  auto scanResult=file.ScanVideoFile("AA","tt");
  for(auto & i : scanResult)
  {
    std::cout<<i<<", ";
  }
  std::cout<<std::endl;
  return 0;
}
